package com.itheima.app.interceptor;

import com.itheima.domain.db.User;

public class UserHolder {
    //定义线程变量 存储用户的数据
    private static  ThreadLocal<User> local = new ThreadLocal<>();
    //存入数据
    public static void set(User user){
        local.set(user);
    }
    //获得数据
    public static User get(){
        return local.get();
    }
    //获得数据
    public static Long getId(){
        return local.get().getId();
    }
    //将数据从本地线程对象中删除
    public static void remove(){
       local.remove();//将数据从本地线程对象中删除
    }


}
